package cannot.util;

import javax.servlet.http.Cookie;

public class CookieUtil {
	
	//根据名称获取cookie
	public static Cookie getCookie(Cookie[] cookies,String name){
		for(Cookie cookie:cookies){
			if(name.equals(cookie.getName())){
				return cookie;
			}
		}
		return null;
	}
	
	//根据名称删除cookie
	public static Cookie deleteCookie(Cookie[] cookies,String name){
		Cookie cookie = getCookie(cookies,name);
		cookie.setMaxAge(0);
		return cookie;
	}
}
